package com.swyc.osschat.Test.designMode.intermediary.impl;

import com.swyc.osschat.Test.designMode.intermediary.base.Mediator;
import com.swyc.osschat.Test.designMode.intermediary.base.WechatUser;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 具体中介者：群聊
 * @Author: z156940l@outlook.com
 * @className WechatGroup
 * @Date: 2022/6/28 8:56
 */
public class WechatGroup extends Mediator {
    //存储同事类
    private List<WechatUser> list = new ArrayList<>();

    @Override
    public void register(WechatUser wechatUser) {
        list.add(wechatUser);
    }

    @Override
    public void send(WechatUser wechatUser) {
        for (WechatUser user : list){
            if (!user.equals(wechatUser)){
                user.receive();
            }
        }
    }
}
